﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.Xml.Linq;

namespace 二维码生成工具
{
    /// <summary>
    /// Home.xaml 的交互逻辑
    /// </summary>
    public partial class Home : Page
    {
        

        public Home()
        {
    
            InitializeComponent();
            Xmlshow();

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // View Expense Report
          
            string k=peopleListBox.SelectedItem.ToString();
            string[] sArray = k.Split(':');
        
             


            /* 局部变量定义 */
            int zhongyan = Convert.ToInt32(sArray[0]);

            switch (zhongyan)
            {
                case 1:
                    MessageBox.Show("还米有页面！");
                    break;
                case 2:
                    Hnzy Hnzy = new Hnzy();
                    this.NavigationService.Navigate(Hnzy);
                    break;
                case 3:
                    MessageBox.Show("还米有页面！");
                    break;
                case 4:
                    MessageBox.Show("还米有页面！");
                    break;
                default:
                    MessageBox.Show("还米有页面！");
                    break;
            }

        }


        

        public void Xmlshow()//显示xml文件的信息
        {
            

            XmlDocument xmldoc = new XmlDocument();

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreComments = true;//忽略文档里面的注释

            XmlReader reader = XmlReader.Create(@".\config\zhongyan.xml", settings);

            xmldoc.Load(reader);

            reader.Close();

            // XmlNode xmlNode = xmldoc.SelectSingleNode("Root");

            //XmlNodeList list= xmlNode.ChildNodes;

            XmlElement rootElem = xmldoc.DocumentElement;
            XmlNodeList list = rootElem.GetElementsByTagName("yan"); //获取person子节点集合
           
            for (int i = 0; i < list.Count; i++)
            {
                peopleListBox.Items.Add(((XmlElement)list.Item(i)).GetAttribute("id") + ":"+ ((XmlElement)list.Item(i)).GetAttribute("name"));
              
            }
        }
    }
}
